package com.scau.ums.util.dao;

import com.scau.ums.model.News;
import org.apache.ibatis.session.SqlSession;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

public class NewsSql {
    public String InsertNews(News schoolnews){
        News anew=schoolnews;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateStr = format.format(anew.getDate());

        String sql= "INSERT INTO `ums`.`news`(`title`, `date`, `content`) VALUES (" ;

        sql=sql+"'"+anew.getTitle()+"'"+","+"'"+dateStr+"'"+","+"'"+anew.getContent()+"'"+");\n";
        return sql;
    }

    public  String SelectNews(){
        String sql="Select * from   `ums`.`news` order by date desc";
        return sql;
    }

    public String countNews(){
        String sql = "SELECT COUNT(*) FROM `ums`.`news` ";
        return sql;
    }
}
